
<%@page import="org.example.www.FacadeInterfaceServiceStub.NewsFacade"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%//@page import="org.example.ws.FacadeStub.News"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%
NewsFacade[] newsarray = null;
newsarray = (NewsFacade[])session.getAttribute("NewsData");
%>  
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>SJSU Search Engine</title>
<style type="text/css">    
            .pg-normal {
                color: black;
                font-weight: normal;
                text-decoration: none;    
                cursor: pointer;    
            }
            .pg-selected {
                color: black;
                font-weight: bold;        
                text-decoration: underline;
                cursor: pointer;
            }
</style>
<script type="text/javascript" src="paging.js"></script>
<script src="datetimepicker.js"></script>
<link href="styles.css" rel="stylesheet" type="text/css" media="screen" />
 
</head>
  
  
<body>
  <script type="text/javascript">
	function ChangeDropdowns(value){
	if(value=="newsbykeyword"){
		document.getElementById('newsbykeyword').style.display='block';
		document.getElementById('newsbycategory').style.display='none';
       }
	else if(value=="newsbycategory"){
		document.getElementById('newsbykeyword').style.display='none';
		document.getElementById('newsbycategory').style.display='block';
	}
	else
		{
		alert("No Matching found");
		}
		}
	</script>
        <!-- Header Starts here... -->
        <jsp:include page="header.jsp" flush="true" /> 
        <!-- Header ends here... -->
            <!-- Add your content here... -->

<form method="post" action="NewsFacadeServlet">
            <div>
            <center>
            <table align ="center">
            <tr>
				<th colspan="2">
				<font size="2" color="red"><sup>*</sup> Required Fields</font></th>
			</tr>
           	<tr>

           	<td colspan="3">
				<% String serverException = (String)request.getAttribute("ServerMessage");
						if(serverException != null){
						%><br> <label style="size: 32; color: red"><%=serverException%></label> <%} %>
			</td></tr>   
               </table>
               <table border="2" align="center">
               <tr>
               <td>
               <h2>News Search</h2>  
               </td>
               <td>
					<SELECT id="SortBased" name="SortBased" onchange="ChangeDropdowns(this.value);">
						<OPTION value="" selected>- Select -</OPTION>	
						<OPTION value="newsbykeyword">News By Keyword</OPTION>
						<OPTION value="newsbycategory">News By Category</OPTION> 
					</SELECT>
               </td>
              
               <td>  
             
               <input id="newsbykeyword" name="newsbykeyword" style="display: none" type="text" size="25"  style="background-color:white;" align="middle" />
               
             
			  <SELECT id="newsbycategory" name="newsbycategory"  style="display: none">
				<OPTION value="Academics">Academics</OPTION>
				<OPTION value="Campus">Campus</OPTION>
				<OPTION value="Associated Students">Associated Students</OPTION>

				<OPTION value="Achievements">Achievements</OPTION>
				<OPTION value="community">community</OPTION>
				<OPTION value="Featured">Featured</OPTION>
				<OPTION value="News">News</OPTION>
				<OPTION value="research">research</OPTION>
				<OPTION value="sjsu">sjsu</OPTION>
				<OPTION value="Student Life">Student Life</OPTION>
				<OPTION value="students">students</OPTION>
				<OPTION value="Twitter">Twitter</OPTION>
				
				<OPTION value="Cesar E. Chavez Community Action Center">Cesar E. Chavez Community Action Center</OPTION>
				<OPTION value="School of Journalism and Mass Communications">School of Journalism and Mass Communications</OPTION>
				<OPTION value="International and Extended Studies">International and Extended Studies</OPTION>
				<OPTION value="College of Applied Arts and Sciences">College of Applied Arts and Sciences</OPTION>
				<OPTION value="College of Applied Sciences and Arts">College of Applied Sciences and Arts</OPTION>
				<OPTION value="College of Business">College of Business</OPTION>
				<OPTION value="College of Humanities and the Arts">College of Humanities and the Arts</OPTION>
				<OPTION value="College of Social Sciences">College of Social Sciences</OPTION>
				<OPTION value="animation/illustration">animation/illustration</OPTION>

				</SELECT>
				
			   </td>
               
               <td colspan="3">
	               <p align="right"><input type="submit" name="buttonHit" value="Search"/></p>
	               </td>
               </tr>             
               </table>     
            </center>                    
            </div> 
              <div>
             	
            <%
            if(newsarray != null)
            { 
            	if(newsarray.length >0)
             	{
             %>
             	<table border="2"  id="results" align="center" width = 90%>
             	<tr>
					<th align="center" style="color:red" bordercolor="red">News Title/ Link</th>
					<th align="center" style="color:red" bordercolor="red">Description</th>
					<th align="center" style="color:red" bordercolor="red">Author</th>
					<th align="center" style="color:red" bordercolor="red">Publication Date</th>
					<th align="center" style="color:red" bordercolor="red">Category</th>

				</tr>

				<%
					for(int i=0;i<newsarray.length;i++)
					{
				%>
					<tr>
					<td bordercolor="black" width="25">
					 	<a href="newsarray[i].getNews_link()"><label id ="restaurant_id" style="size: 25;"><%=newsarray[i].getNews_title() %></label></a>
					</td>
					
					<td bordercolor="black">
					 	<label id ="restaurant_name" style="size: 25;"><%=newsarray[i].getNews_description() %></label> 
					</td>
					<td bordercolor="black">
					 	<label id ="cuisine" style="size: 25;"><%=newsarray[i].getNews_author() %></label> 
					</td>
					<td bordercolor="black">
					 	<label id ="restaurant_rating" style="size: 25;"><%=newsarray[i].getNews_publication_date() %></label> 
					</td>
					<td bordercolor="black">
					 	<label id ="restaurant_latitude" style="size: 25;"><%=newsarray[i].getNews_category() %></label> 
					</td>
					
					</tr>					
	            <%
					}
				%>
				</table>
					<div id="pageNavPosition" align="center"></div>
					
					 <script type="text/javascript"><!--
        				var pager = new Pager('results', 5); 
        				pager.init(); 
        				pager.showPageNav('pager', 'pageNavPosition'); 
        				pager.showPage(1);
    				//--></script>
				<%
				}
				else
				{%>
				<label>No Records Found</label>

				<%
				} 
             	}
             	%>
             </div>
         </form>
       
    </body>
</html>